package com.estudos.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.estudos.model.Usuario;
import com.estudos.service.UsuarioService;

@Controller
@RequestMapping(value="usuario")
public class UsuarioController {
	@Autowired
	UsuarioService usuService;
	
	public UsuarioController(){
		System.out.println("aaaaaaaaaaaa Inicializou o loginController!");
	}
	@RequestMapping(value="/login")
	public ModelAndView showPageLogin(){
		
		return null;
	}
	
	@RequestMapping(value = "/")
	public ModelAndView listarUsuarios(){
		return usuService.listarUsuarios();
	}
	@RequestMapping(value="novo")
	public ModelAndView novoUsuario(){
		return usuService.novoUsuario();
	}
	
	@RequestMapping(value="cadastrar")
	public void persistir(Usuario usuario){
		System.out.println("AAAAAAAAA chegou no PERSISTIR");
		usuService.persistir(usuario);
	}
	
	@RequestMapping(value="editar")
	public ModelAndView iniciarEditar(int id){
		return usuService.iniciarEditar(id);
	}
	@RequestMapping(value="excluir")
	public void remover(int id){
		usuService.remover(id);
	}
	
}
